<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: banner_infobox.php 11 2013-09-21 11:43:11Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 11 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-21 11:43:11 +0000 (Sat, 21 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */


require(DIR_WS_CLASSES . 'phplot.php');

$stats = array();
$banner_stats = $db->db_query("	SELECT 
									dayofmonth(banners_history_date) AS name, 
									banners_shown AS value, 
									banners_clicked AS dvalue 
								FROM 
									" . TABLE_BANNERS_HISTORY . " 
								WHERE 
									banners_id = '" . $banner_id . "' 
								AND 
									TO_DAYS(NOW()) - TO_DAYS(banners_history_date) < " . $days . " 
								ORDER BY 
									banners_history_date");

while (!$banner_stats->EOF) {
	$stats[] = array($banner_stats->fields['name'], $banner_stats->fields['value'], $banner_stats->fields['dvalue']);
	$banner_stats->MoveNext();
}

if (sizeof($stats) < 1) $stats = array(array(date('j'), 0, 0));

$graph = new PHPlot(200, 220, 'images/graphs/banner_infobox-' . $banner_id . '.' . $banner_extension);

$graph->SetFileFormat($banner_extension);
$graph->SetIsInline(1);
$graph->SetPrintImage(0);

$graph->draw_vert_ticks = 0;
$graph->SetSkipBottomTick(1);
$graph->SetDrawXDataLabels(0);
$graph->SetDrawYGrid(0);
$graph->SetPlotType('bars');
$graph->SetDrawDataLabels(1);
$graph->SetLabelScalePosition(1);
$graph->SetMarginsPixels(15,15,15,30);

$graph->SetTitleFontSize('4');
$graph->SetTitle('3 Day Statistics');

$graph->SetDataValues($stats);
$graph->SetDataColors(array('blue','red'),array('blue', 'red'));

$graph->DrawGraph();

$graph->PrintImage();
?>